<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<c:set var="roleDeleteVisable" value="${d:accessUri('/role/role-delete.do',pageContext.request) }"></c:set>
<c:set var="roleEditVisable" value="${d:accessUri('/role/role-edit.do',pageContext.request) }"></c:set>
<c:set var="roleQueryVisable" value="${d:accessUri('/role/role-query.do',pageContext.request) }"></c:set>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>角色列表</title>
		<%@ include file="/global/tablesort-header.jsp"%>
		<script>
		var rs = "${pager.list.size()}";
		rs = ((!rs)? 0 : parseInt(rs))+1;
		var h = rs * 27 + 50;
		$(window.parent.document).find("#queryResult").removeClass("hide");
		$(window.parent.document).find("#queryResultIframe").height(h);
		
		<c:if test="${superManager || roleQueryVisable}">
		function rbacSettiing(roleId,type){
			<c:if test="${superManager }">
			if(type == 1){
				window.parent.replaceCurIframe("权限分配","/rbac/rbac-setting-input.do?roleId="+roleId);
			}else if(type == 2){
				window.parent.replaceCurIframe("角色菜单可见分配","/rbac/role-menu-input.do?roleId="+roleId);
			}
			</c:if>
			<c:if test="${roleQueryVisable }">
			if(type == 3){
				window.parent.replaceCurIframe("角色菜单可见分配","/role/worker-role-input.do?role.roleId="+roleId);
			}
			</c:if>
		}
		</c:if>
		</script>
	</head>
	<body>
		<c:if test="${pager.list.size() > 0}">
			<div class="pagertoleft clearBoth">
				<%@ include file="/global/pager-default.jsp"%>
			</div>
			<table id="myTable" cellspacing="1" class="tablesorter">
				<thead>
					<tr>
						<th>
							角色编号
						</th>
						<th>
							角色名称
						</th>
						<th>
							角色优先级
						</th>
						<th width="250px">
							操作
						</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${pager.list }" var="item">
						<tr roleId=${item.roleId }>
							<td>
								${item.roleId }
							</td>
							<td>
								${item.roleName }
							</td>
							<td>
								${item.orderNo }
							</td>
							<td width="250px">
								<c:if test="${roleEditVisable}">
								<a href="#" onclick="globalEdit(${item.roleId})">编辑</a>
								</c:if>
								<c:if test="${superManager }">
									<a href="#" onclick="rbacSettiing(${item.roleId},1)">权限分配 </a>
									<a href="#" onclick="rbacSettiing(${item.roleId},2)">可见菜单</a>
								</c:if>
								<c:if test="${roleQueryVisable}">
								<a href="#" onclick="rbacSettiing(${item.roleId},3)">人员分配 </a>
								</c:if>
								<c:if test="${roleDeleteVisable}">
								<a href="#" onclick="globalDelete(${item.roleId })">删除</a>
								</c:if>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</c:if>
		<c:if test="${pager.list.size() <= 0}">
			<div class="emptyResult">
				抱歉，没有找到相关角色。
			</div>
		</c:if>
	</body>
</html>
